-- tree_house
-- created by cheny3
-- 地牢格子：树屋

return {
    restoreGrid = function(grid, info)
        -- 还原状态
        local treeHouse = grid.tree_house;

        if info["tree_house"]["action"] then
            treeHouse.action = info["tree_house"]["action"];
        end

        if info["tree_house"]["active"] then
            treeHouse.active = info["tree_house"]["active"];
        end

        local skills = info["tree_house"]["skills"];
        if skills then
            if skills.array then
                info["tree_house"]["skills"] = skills:toTable();
                treeHouse:setSkills(skills:toTable());
            else
                treeHouse:setSkills(skills);
            end
        end

        treeHouse.dbase:aborb(info["tree_house"]);
    end,

    collectContext = function(grid)
        local treeHouse = grid.tree_house;

        local ret = treeHouse:getSaveData();

        if treeHouse:isActive() then
            ME.user.dbase:set("tree_house", ret);
        end

        return {["tree_house"] = ret, };
    end
};
